
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    
        
    <style type="text/css">
    body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }
    </style>
</head>
<body>
    <div class="mini-toolbar" style="text-align:center;line-height:30px;" borderStyle="border:0;">
          <label >物料名称：</label>
          <input id="key" class="mini-textbox" style="width:150px;" onenter="onKeyEnter"/>
          <a class="mini-button" style="width:60px;" onclick="search()">查询</a> <a class="mini-button" style="width:60px;" onclick="onButtonEdit()">创建新物料</a>
    </div>
    <div class="mini-fit">

        <div id="grid1" class="mini-datagrid" style="width:100%;height:100%;" 
            idField="id" allowResize="true" showPager="false"
            borderStyle="border-left:0;border-right:0;" onrowdblclick="onRowDblClick"
        >
            <div property="columns">
                 <div field="sap_code"  headerAlign="center"  >SAP编号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
           
             <div field="item_name"  headerAlign="center"  >物料名称
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="logo"  headerAlign="center"  >Logo
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="pm"  headerAlign="center"  >产品经理
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            
             <div field="color"  headerAlign="center"  >颜色
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="model"  headerAlign="center"  >型号
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            <div field="specifications"  headerAlign="center"  >规格
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
              <div field="weight"  headerAlign="center"  >重量
                <input property="" class="mini-textbox" style="width:100%;" />
            </div>
            
            
            <div field="brand_name"  headerAlign="center"  >品牌
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="is_serial"  headerAlign="center"  >是否为序列号管理
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
            <div field="is_3c"  headerAlign="center"  >是否为3C
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
          
         
          
            <div field="ctime"  headerAlign="center"  >添加时间
                <input property="" class="mini-textbox" style="width:100%;" />
            </div> 
                                                          
            </div>
        </div>
    
    </div>                
    <div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;" borderStyle="border:0;">
        <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
        <span style="display:inline-block;width:25px;"></span>
        <a class="mini-button" style="width:60px;" onclick="onCancel()">取消</a>
    </div>

</body>
</html>
<script type="text/javascript">
    mini.parse();

    var grid = mini.get("grid1");
    grid.setPageSize(100);
   
    grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;

            //格式化日期
            if (field == "ctime") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
				
            }
          
            
            if (field == "item_name") {
            	var url="/SapSupplier/itemedit/id/";
                e.cellHtml = '<a href="' + url+record.item_id + '"  target="_blank"  >' +value+ '</a>';
            }
            
            
            if (field == "logo") {
                var imgUrl = value.split(",");
                //e.cellHtml = '<img src="' + value + '"  style="width:50px" >';
                e.cellHtml = '<img src="' + imgUrl[0] + '"  style="width:50px" >';
            }
            
         

        });
    
    
    grid.setUrl("/index.php?m=&c=SapSupplier&a=getItemListData");
    //也可以动态设置列 grid.setColumns([]);

    //grid.load();

    function GetData() {
        var row = grid.getSelected();
        return row;
    }
    function search() {
        var key = mini.get("key").getValue();
        grid.load({ c_name: key });
    }
    function onKeyEnter(e) {
        search();
    }
    function onRowDblClick(e) {
        onOk();
    }
    //////////////////////////////////
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onOk() {
        CloseWindow("ok");
    }
    function onCancel() {
        CloseWindow("cancel");
    }

    function onButtonEdit(e) {
        var btnEdit = this;

        mini.open({
            url:  "/SapSupplier/itemadd",
            title: "创建新物料",
            width: 650,
            height: 380,
            ondestroy: function (action) {

                if (action == "ok") {
                    var iframe = this.getIFrameEl();

                    var data = iframe.contentWindow.GetData();
                    data = mini.clone(data);
                    btnEdit.setValue(data.id);
                    btnEdit.setText(data.text);
                }
            }
        });

    }

</script>